<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">
                <h:form>
                    <p:panel id="panelReport" >
                        <f:facet name ="header" >
                            <h:outputLabel styleClass="noPrintButton"  value="Logins Report" />
                            <p:calendar styleClass="noPrintButton" value="#{loginController.fromDate}" pattern="dd MMMM yyyy hh:mm:ss a" >
                            </p:calendar>
                            <p:calendar styleClass="noPrintButton" value="#{loginController.toDate}" pattern="dd MMMM yyyy hh:mm:ss a" >
                            </p:calendar>

                            <p:commandButton id="btnRefresh" actionListener="#{loginController.fillLogins()}"
                                             styleClass="noPrintButton" value="Process"
                                             ajax="false" 
                                             onclick="onSubmitButton();">                               
                            </p:commandButton>
                            <p:defaultCommand target="btnRefresh"/>
                            
                            <p:commandButton styleClass="noPrintButton" value="Print" ajax="false" >
                                <p:printer target="panelReport" />
                            </p:commandButton>
                            
                        </f:facet>


                        <p:panel styleClass="printBlock" >
                            <h:outputLabel value="#{labels.topic}" styleClass="rh1" style="font-size: 18px;" /> 
                            <br/>
                            <h:outputLabel value="Login Details Report" />
                            <br/>
                            <h:outputLabel value="From : " />
                            <h:outputLabel value="#{loginController.fromDate}"  >
                                <f:convertDateTime pattern="dd MMMM yyyy hh:mm:ss a" />
                            </h:outputLabel>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <h:outputLabel value="To : "  ></h:outputLabel>
                            <h:outputLabel value="#{loginController.toDate}" >
                                <f:convertDateTime pattern="dd MMMM yyyy hh:mm:ss a" />
                            </h:outputLabel>

                        </p:panel>

                        <p:dataTable value="#{loginController.logins}" var="b" >
                            <p:column headerText="Institution" >
                                <h:outputLabel value="#{b.institution.name}" ></h:outputLabel>
                            </p:column>
                            <p:column headerText="Department">
                                <h:outputLabel value="#{b.department.name}" ></h:outputLabel>
                            </p:column>
                            <p:column headerText="Code">
                                <h:outputLabel value="#{b.webUser.code}" >
                                </h:outputLabel>
                            </p:column>
                            <p:column headerText="Name">
                                <h:outputLabel value="#{b.webUser.webUserPerson.name}" >
                                </h:outputLabel>
                            </p:column>
                            <p:column headerText="Login At">
                                <h:outputLabel value="#{b.logedAt}" >
                                    <f:convertDateTime pattern="dd MM yy hh:mm:ss a" />
                                </h:outputLabel>
                            </p:column>
                            <p:column headerText="Log out at">
                                <h:outputLabel value="#{b.logoutAt}" >
                                    <f:convertDateTime pattern="dd MM yy hh:mm:ss a" />
                                </h:outputLabel>
                            </p:column>
                            <p:column headerText="IP">
                                <h:outputLabel value="#{b.ipaddress}" >
                                </h:outputLabel>
                            </p:column>

                        </p:dataTable>

                    </p:panel>

                </h:form>
            </ui:define>



        </ui:composition>

    </h:body>
</html>
